const express = require("express");
const app = express();
const admin = require("./admin");
const banner = require("./banner");
const common = require("./common");
const active = require("./active");
const reigster = require("./reigster");

// 跨域设置
app.all("*", function (req, res, next) {
  res.setHeader("Access-Control-Allow-Credentials", true);
  // res.setHeader("Access-Control-Allow-Origin", req.get("Origin")); // 添加这一行代码，代理配置不成功
  res.setHeader(
    "Access-Control-Allow-Methods",
    "POST, GET, OPTIONS, DELETE, PUT"
  );
  res.header(
    "Access-Control-Allow-Headers",
    "Origin, X-Requested-With, Content-Type, Accept, If-Modified-Since"
  );
  next();
});
app.use("/", admin);
app.use("/", banner);
app.use("/", common);
app.use("/", active);
app.use("/", reigster);

app.listen(4000, () => {
  console.log(4000);
});
